$(document).ready(function() {
	var id = getvl("id");
	getOrdersDetail(id);
});

/*
 * 获取用户详情
 */
function getOrdersDetail(id) {
	$.ajax({
		url: urlcore + "/api/orders/ordersDetail?id=" + id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
				var da = data.data;
				var passtime = formatDate(da.passTime,"yyyy-MM-dd hh:mm:ss");
				var refundtime = formatDate(da.refundTime,"yyyy-MM-dd hh:mm:ss");
				var finishtime = formatDate(da.finishTime,"yyyy-MM-dd hh:mm:ss");
				
				var overduetime = formatDate(da.overdueTime,"yyyy-MM-dd hh:mm:ss");
				var givetime = formatDate(da.giveTime,"yyyy-MM-dd hh:mm:ss");
				var refundpasstime = formatDate(da.refundPassTime,"yyyy-MM-dd hh:mm:ss");
				$('#real_name').val(da.user.realName);
				$('#phone').val(da.user.phone);
				$('#product_name').val(da.product.productName);
				$('#pass_time').val(passtime);
				$('#refund_time').val(refundtime);
				$('#finish_time').val(finishtime);
				$('#city').val(da.address.city);
				$('#area').val(da.address.area);
				$('#province').val(da.address.city);
				$('#province').val(da.address.province)	;
				$('#address_detail').val(da.address.addressDetail);
				$('#price').val(da.price);
				$('#order_price').val(da.orderPrice);
				$('#number').val(da.number);
				
				$('#real_pay_money').val(da.realPayMoney);
				$('#need_pay_money').val(da.needPayMoney);
				$('#waste_money').val(da.wasteMoney);
				$('#limit_days').val(da.limitDays);
				$('#overdue_time').val(overduetime);
				$('#give_time').val(givetime);
				$('#overdue_days').val(da.overdueDays);
				$('#overdue_money').val(da.overdueMoney);
				$('#refund_pass_time').val(refundpasstime);
				$('#push_remark').val(da.pushRemark);
				$('#pass_remark').val(da.passRemark);
				
				
				
			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
}
function formatDate(dateTime,format){
    return null==dateTime?"":new Date(dateTime).pattern(format);
}